package thread.assignment.url;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class URLRunnable implements Runnable {

	URL url;
	//HttpURLConnection conn;
	
	URLRunnable(URL url){
		this.url = url;
	}
	
	@Override
	public void run() {
		String line;
		//int totalLines = 0;
		
		/*try{
			conn = (HttpURLConnection) url.openConnection();
			conn.setRequestMethod("GET");
		}catch (IOException e) {
			e.printStackTrace();
		}*/

		try (BufferedReader reader = new BufferedReader(new InputStreamReader(
				url.openStream()))) {
			
			int totalLines = 0;
			while ((line = reader.readLine()) != null) {
				totalLines += line.length();
			}
			
			//System.out.println(totalLines);
			
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
